{if $smarty.get.print != 1}
  {include file="header.tpl"}
{else}
  {include file="headerPrint.tpl"}
{/if}
<style>
.aavakColor
{
  color:red;
}
.javakColor
{
  color:green;
}
</style>
<script type="text/javascript">
function deleteRow(vepaariBookDetailId)
{
  if(confirm("Warning: Are you sure?\nDeletion is permanent. Continue anyway.") && confirm("Warning: Are you sure?\nDeletion is permanent. Continue anyway."))
  {
    location.href = "vepaaribillDelete.php?vepaariBookDetailId="+vepaariBookDetailId;
  }
}
function bookFunction(id)
{
  document.form1.bdate.value="0";
  document.form1.submit();
}
</script>
<form name="form1" action="" method="post">
<input type="hidden" name="bdate" id="bdate" value="0" />
<center><h4>Vepaari Detail</h4></center>
<div class="contentDiv">
  <table border="0" align="center" width="100%" cellspacing="0" cellpadding="0">
  {* Header Part Start*}
  <tr><td colspan="10"><hr COLOR="#000000" /></td></tr>
  <tr>
    <td class="table1">
      Party  : 
      <select name="party" onchange="bookFunction();">
        {html_options values=$party.partyId	 output=$party.partyName selected={$partyId}}
      </select>
    </td>
    <td colspan="9" class="table1" nowrap>
      From :
      {html_select_date prefix="fromDate" start_year="-2" end_year="+1" field_order="DMY" day_value_format="%02d" time=$fromDateSelected}
      To: 
      {html_select_date prefix="toDate" start_year="-2" end_year="+1" field_order="DMY" day_value_format="%02d" time=$toDate}   
      <input type="submit" name="submitBtn" value="Find" />
      {if $smarty.get.print != 1}
        <a href="vepaariBookListNew.php?print=1&fromDate={$fromDateSelected}&toDate={$toDate}&party={$partyId}">Print</a>
      {else}
        &nbsp;
      {/if}
    </td>
  </tr>
  {* Header Part End *}
  {if $smarty.get.print != 1}
  {else}
  <tr class="table2">
    <td colspan="10"><hr COLOR="#000000" /></td></tr>
  {/if}
  <tr class="table1" >
    <th align="center" colspan="2" class="aavakColor">Aavak</th>
  </tr>
  <tr>  
    <td vAlign="top" colspan="2">
     <table border="1" align="center" width="100%" cellspacing="0" cellpadding="1" class="aavakColor">
       <tr class="table1">  
         {if $smarty.get.print != 1}
           <td width="8%">&nbsp;</td>
         {else}
           &nbsp;
         {/if}
         <td width="10%" align="center" style="border-right:1px;">Date</td>
         <td width="27%" align="center" style="border-right:1px;" >Particulars</td>
         <td width="8%" align="center" style="border-right:1px;" >N.Wght</td>
         <td width="8%" align="center" style="border-right:1px;" >Touch</td>
         <td width="8%" align="center" style="border-right:1px;" >Waste</td>
         <td width="8%" align="center" style="border-right:1px;" >Fine</td>
         <td width="8%" align="center" style="border-right:1px;" >Qty</td>
         <td width="8%" align="center" style="border-right:1px;" >Labour</td>
         <td align="center" style="border-right:1px;" >Amt</td>
       </tr>
       <tr class="table1">
         {if $smarty.get.print != 1}
      	   <td>&nbsp;</td>
      	 {/if}
         <td style="border-right:1px;">&nbsp;&nbsp;</td>
         <td style="border-right:1px;">&nbsp;&nbsp;</td>
      	 <td style="border-right:1px;">&nbsp;&nbsp;Opening</td>
      	 <td style="border-right:1px;">&nbsp;</td>
      	 <td style="border-right:1px;">&nbsp;</td>
      	 <td style="border-right:1px;">&nbsp;</td>
      	 <td style="border-right:1px;">&nbsp;</td>
         <td style="border-right:1px;" align="right">{if $openingFinalFineCr != 0}{$openingFinalFineCr|string_format:"%.0f"}{else}&nbsp;{/if}</td>
         <td style="border-right:1px;" align="right">{if $openingFinalAmountCr != 0}{$openingFinalAmountCr|string_format:"%.0f"}{else}&nbsp;{/if}</td>
      </tr>
      {section name="sec" loop=$billDetailCreditArray|@count}
        {if $smarty.section.sec.index != 0 && $billDetailCreditArray[sec].vepaariBookMasterId != $billDetailCreditArray[sec-1].vepaariBookMasterId}
          {* <tr class="table2"><td colspan="11"><hr/></td></tr> *}
        {/if}
      <tr>
      
      {if $smarty.get.print != 1}
        <td width="150">
          {if $billDetailCreditArray[sec].vepaariBookMasterId != $billDetailCreditArray[$smarty.section.sec.index-1].vepaariBookMasterId}
            <a href="vepaariBookListNewAavak.php?print=1&vepaariBookMasterId={$billDetailCreditArray[sec].vepaariBookMasterId}&partyId={$billDetailCreditArray[sec].partyId}&vepaariBookDate={$billDetailCreditArray[sec].vepaariBookDate}">Print</a>
          {else}
            &nbsp;
          {/if}
          {if $billDetailCreditArray[sec].vepaariBookMasterId != $billDetailCreditArray[$smarty.section.sec.index-1].vepaariBookMasterId}<a href="javascript:deleteRow({$billDetailCreditArray[sec].vepaariBookDetailId})"><img src="./images/b_drop.png" border="0" width="15" height="15"></a>
          {else}
            &nbsp;
          {/if}
          {if $billDetailCreditArray[sec].vepaariBookMasterId != $billDetailCreditArray[$smarty.section.sec.index-1].vepaariBookMasterId}<a href="vepaariBookAavak.php?vepaariBookMasterId={$billDetailCreditArray[sec].vepaariBookMasterId}"><img src="./images/b_edit.png" border="0" width="15" height="15"></a>
          {else}
            &nbsp;
          {/if}
      {else}
        &nbsp;
      {/if}
      </td>
        <td align="center" style="border-right:1px;" NOWRAP>&nbsp;{$billDetailCreditArray[sec].vepaariBookDate|date_format:"%d-%m-%Y"}</td>
        <td align="left" style="border-right:1px;">{$billDetailCreditArray[sec].particulars}</td>
        <td align="right" style="border-right:1px;">{if $billDetailCreditArray[sec].netWeight != 0}{$billDetailCreditArray[sec].netWeight|string_format:"%.0f"}{else}&nbsp;{/if}</td>
        <td align="right" style="border-right:1px;">{if $billDetailCreditArray[sec].touch != 0}{$billDetailCreditArray[sec].touch|string_format:"%.2f"}{else}&nbsp;{/if}</td>
        <td align="right" style="border-right:1px;">{if $billDetailCreditArray[sec].waste != 0}{$billDetailCreditArray[sec].waste|string_format:"%.2f"}{else}&nbsp;{/if}</td>
        <td align="right" style="border-right:1px;">{if $billDetailCreditArray[sec].fine != 0}{$billDetailCreditArray[sec].fine|string_format:"%.0f"}{else}&nbsp;{/if}</td>
        <td align="right" style="border-right:1px;">{if $billDetailCreditArray[sec].qty != 0}{$billDetailCreditArray[sec].qty|string_format:"%.0f"}{else}&nbsp;{/if}</td>
        <td align="right" style="border-right:1px;">{if $billDetailCreditArray[sec].labour != 0}{$billDetailCreditArray[sec].labour|string_format:"%.0f"}{else}&nbsp;{/if}</td>
        <td align="right" style="border-right:1px;">{if $billDetailCreditArray[sec].amount != 0}{$billDetailCreditArray[sec].amount|string_format:"%.0f"}{else}&nbsp;{/if}</td>
      </tr>
      {/section}
      {section name="sec1" loop=$extraBillDetailCredit}
      {/section}
      <tr>
        <td colspan="10"><hr COLOR="#000000" /></td>
      </tr>
      <tr class="table1">
        <td style="border-right:1px;" align="right" >Total :&nbsp;&nbsp;&nbsp;</td>
        {if $smarty.get.print != 1}
          <td style="border-right:1px;">&nbsp;</td>
          <td style="border-right:1px;">&nbsp;</td>
          <td style="border-right:1px;">&nbsp;</td>
          <td style="border-right:1px;">&nbsp;</td>
          <td style="border-right:1px;">&nbsp;</td>
        {else}
          <td style="border-right:1px;">&nbsp;</td>
          <td style="border-right:1px;">&nbsp;</td>
          <td style="border-right:1px;">&nbsp;</td>
          <td style="border-right:1px;">&nbsp;</td>
        {/if} 
        <td align="right" style="border-right:1px;">{$totalFineCr|string_format:"%.0f"}</td>
        <td style="border-right:1px;">&nbsp;</td>
        <td style="border-right:1px;">&nbsp;</td>
        <td align="right" style="border-right:1px;">{$totalAmountCr|string_format:"%.0f"}</td>
      </tr>
    </table>
    </td>
  {if $smarty.get.print != 1}
  {else}
  <tr class="table2">
    <td colspan="10"><hr COLOR="#000000" /></td></tr>
  {/if}
  <tr class="table1">
    <th colspan="2" align="center" class="javakColor">Javak</th>
  </tr>    
{* Jaavak Section Start *}
    <td  style="border-right:1px;" vAlign="top" colspan="2">
    <table border="2" align="center" width="100%" cellspacing="0" cellpadding="1"  class="javakColor">
      <tr class="table1">
        {if $smarty.get.print != 1}
      	  <td style="border-right:1px;" width="8%">&nbsp;</td>
      	{else}
          &nbsp;
        {/if}
        <td width="10%" align="center" style="border-right:1px;">Date</td>
        <td width="27%" align="center" style="border-right:1px;">Particulars</td>
        <td width="8%" align="center" style="border-right:1px;">N.Wght</td>
        <td width="8%" align="center" style="border-right:1px;">Touch</td>
        <td width="8%" align="center" style="border-right:1px;">Waste</td>
        <td width="8%" align="center" style="border-right:1px;">Fine</td>
        <td width="8%" align="center" style="border-right:1px;">Qty</td>
        <td width="8%" align="center" style="border-right:1px;">Labour</td>
        <td align="center" style="border-right:1px;">Amt</td>
      </tr>
      <tr class="table1">
      	{if $smarty.get.print != 1}
      	  <td align="right">&nbsp;</td>
      	{/if}  
        <td align="right" style="border-right:1px;">&nbsp;</td> 
        <td align="center" style="border-right:1px;">Opening</td>
        <td align="right" style="border-right:1px;">&nbsp;</td>
        <td align="right" style="border-right:1px;">&nbsp;</td>
        <td align="right" style="border-right:1px;">&nbsp;</td>
        <td align="right" style="border-right:1px;">&nbsp;</td>
        <td align="right" style="border-right:1px;">&nbsp;</td>
        <td align="right" style="border-right:1px;">{if $openingFinalFineDr != 0}{$openingFinalFineDr|string_format:"%.0f"}{else}&nbsp;{/if}</td>
        <td align="right" style="border-right:1px;">{if $openingFinalAmountDr != 0}{$openingFinalAmountDr|string_format:"%.0f"}{else}&nbsp;{/if}</td>
      </tr>
      {section name="sec1" loop=$billDetailDebitArray|@count}
      <tr>
        {if $smarty.get.print != 1}
          {if $billDetailDebitArray[sec1].billNo <= 0}
		        <td>
		          {if $billDetailDebitArray[sec1].vepaariBookMasterId != $billDetailDebitArray[$smarty.section.sec1.index-1].vepaariBookMasterId}
		            <a href="vepaariBookListNewJavak.php?print=1&vepaariBookMasterId={$billDetailDebitArray[sec1].vepaariBookMasterId}&partyId={$billDetailDebitArray[sec1].partyId}&vepaariBookDate={$billDetailDebitArray[sec1].vepaariBookDate}">Print</a>
		          {else}
		            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		          {/if}
		          {if $billDetailDebitArray[sec1].vepaariBookMasterId != $billDetailDebitArray[$smarty.section.sec1.index-1].vepaariBookMasterId}<a href="javascript:deleteRow({$billDetailDebitArray[sec1].vepaariBookDetailId})"><img src="./images/b_drop.png" border="0" width="15" height="15"></a>
		          {else}
		            &nbsp;
		          {/if}
		          {if $billDetailDebitArray[sec1].vepaariBookMasterId != $billDetailDebitArray[$smarty.section.sec1.index-1].vepaariBookMasterId}<a href="vepaariBookJaavak.php?vepaariBookMasterId={$billDetailDebitArray[sec1].vepaariBookMasterId}"><img src="./images/b_edit.png" border="0" width="15" height="15"></a>
		          {else}
		            &nbsp;
		          {/if}
		        </td>
		      {else}  
		        <td align="right">&nbsp;</td>
          {/if}
        {else}
          &nbsp;
        {/if}
        <td align="center" style="border-right:1px;"  nowrap>&nbsp;{$billDetailDebitArray[sec1].vepaariBookDate|date_format:"%d-%m-%Y"}</td>
        {if $billDetailDebitArray[sec1].billNo != 0}
        <td align="right" style="border-right:1px;">Bill No{$billDetailDebitArray[sec1].billNo}</td>
        {else}
        <td align="left" style="border-right:1px;">{$billDetailDebitArray[sec1].particulars}</td>
        {/if}
        <td align="right" style="border-right:1px;">{if $billDetailDebitArray[sec1].netWeight != 0}{$billDetailDebitArray[sec1].netWeight|string_format:"%.0f"}{else}&nbsp;{/if}</td>
        <td align="right" style="border-right:1px;">{if $billDetailDebitArray[sec1].touch != 0}{$billDetailDebitArray[sec1].touch|string_format:"%.2f"}{else}&nbsp;{/if}</td>
        <td align="right" style="border-right:1px;">{if $billDetailDebitArray[sec1].waste != 0}{$billDetailDebitArray[sec1].waste|string_format:"%.2f"}{else}&nbsp;{/if}</td>
        <td align="right" style="border-right:1px;">{if $billDetailDebitArray[sec1].fine != 0}{$billDetailDebitArray[sec1].fine|string_format:"%.0f"}{else}&nbsp;{/if}</td>
        <td align="right" style="border-right:1px;">{if $billDetailDebitArray[sec1].qty != 0}{$billDetailDebitArray[sec1].qty|string_format:"%.0f"}{else}&nbsp;{/if}</td>
        <td align="right" style="border-right:1px;">{if $billDetailDebitArray[sec1].labour != 0}{$billDetailDebitArray[sec1].labour|string_format:"%.0f"}{else}&nbsp;{/if}</td>
        <td align="right" style="border-right:1px;">{if $billDetailDebitArray[sec1].amount != 0}{$billDetailDebitArray[sec1].amount|string_format:"%.0f"}{else}&nbsp;{/if}</td>
      </tr>
      {/section}
      {section name="sec1" loop=$extraBillDetailDebit}
      {/section}
		  <tr>
		    <td colspan="10"><hr COLOR="#000000" /></td>
		  </tr>
      <tr class="table1">
        <td align="right" style="border-right:1px;">Total :&nbsp;&nbsp;&nbsp; </td>
        {if $smarty.get.print != 1}
          <td style="border-right:1px;">&nbsp;</td>
          <td style="border-right:1px;">&nbsp;</td>
          <td style="border-right:1px;">&nbsp;</td>
          <td style="border-right:1px;">&nbsp;</td>
          <td style="border-right:1px;">&nbsp;</td>
          {else}
          <td style="border-right:1px;">&nbsp;</td>
          <td style="border-right:1px;">&nbsp;</td>
          <td style="border-right:1px;">&nbsp;</td>
          <td style="border-right:1px;">&nbsp;</td>
        {/if} 
          <td align="right" style="border-right:1px;">{$totalFineDr|string_format:"%.0f"}</td>
          <td style="border-right:1px;">&nbsp;</td>
          <td style="border-right:1px;">&nbsp;</td>
          <td align="right" style="border-right:1px;">{$totalAmountDr|string_format:"%.0f"}</td>
      </tr>
    </table>
    </td>
  </tr>
  </table>
  <table>
  <tr align="left">
  <td align="left">
    <b style="color:green;">{if $total.totFine >= 0} Total Debit Fine:{else}</b><b style="color:red;"> Total Credit Fine:{/if} {$total.totFine|string_format:"%.0f"}</b><br>
    <b style="color:green;">{if $total.totAmount >= 0} Total Debit Amount:{else}</b><b style="color:red;"> Total Credit Amount:{/if} {$total.totAmount|string_format:"%.0f"}</b>
  </td>
  </tr>
</table>   
  {* Jaavak Section End *}
</div>
</form>
{if $smarty.get.print != 1}
  {include file="footer.tpl"}
{/if}
